package com.heima.admin.controller.v1;

import com.heima.apis.admin.IAdminClient;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HYK
 * @date 2022/10/22
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    @Autowired
    private IAdminClient iAdminClient;

    /**
     * 列表
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/list")
    ResponseResult list(@RequestBody ChannelDto dto) {
        return iAdminClient.list(dto);
    }

    /**
     * 新增频道
     *
     * @param wmChannel wm通道
     * @return {@link ResponseResult}
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return iAdminClient.saveChannel(wmChannel);
    }

    /**
     * 修改频道
     *
     * @param wmChannel wm通道
     * @return {@link ResponseResult}
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel) {
        return iAdminClient.updateChannel(wmChannel);
    }

    /**
     * 删除频道
     *
     * @param id id
     * @return {@link ResponseResult}
     */
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id) {
        return iAdminClient.deleteChannel(id);
    }

}
